package com.prestamomo.vil.ppa.pmvilnet;

import com.google.gson.JsonParseException;

import org.json.JSONException;

import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.text.ParseException;

import retrofit2.HttpException;

public class PmvilHttpStatusCode {
    public static String handlePmivlException(Throwable pmvile) {
        if (pmvile instanceof HttpException) {
            return "請求失敗";
        } else if (pmvile instanceof JsonParseException
                || pmvile instanceof JSONException
                || pmvile instanceof ParseException) {
            return "解析錯誤";
        } else if (pmvile instanceof ConnectException) {
            return "連線逾時";
        } else if (pmvile instanceof SocketTimeoutException) {
            return "回應超時";
        } else {
            return "未知錯誤";
        }
    }

}
